#coding=utf-8
import os


def ReadFileDatas(path):
    name_list = []
    files = open(path,'r+', encoding='UTF-8')
    for line in files:
        line = line.strip('\n')
        name_list.append(line)
    print('len ( name_list ) :', len(name_list))
    files.close()
    return name_list

def del_files(datas):
    for name in datas:
        try:
            os.remove(os.path.join(root, name))
            print("Delete File:" + os.path.join(root, name))
        except FileNotFoundError:
            print("文件不存在！！！！")
            continue
        
        

if __name__ == "__main__":
    root = r"I:\0_Deep_Learning\磁瓦\磁瓦数据集_1_3_正面--sss\1工位\dataset_split\temp_v/"
    path = r'valid.txt'
    datas = ReadFileDatas(path)
    del_files(datas)